<?php
require_once ("db_connection.php");
	
$q=mysql_query("SELECT
				affiliate.affiliateid
				FROM
				affiliate
				WHERE
				affiliate.companyname = '$_POST[companyname]'");	
	
while($row = mysql_fetch_array($q)){
		$companyid=$row['affiliateid'];
}
session_start();
$pic = $_SESSION['varname'];
$date = date("Y-m-d H:i:s");
$id = "ve-" . uniqid();
	
	$query = "INSERT INTO drivers(driverid,affiliateid,driversname,contactno,image)
		VALUES('$id', '$companyid', '$_POST[name]', '$_POST[contactno]','$pic')";
	
	if(!mysql_query($query, $con)){
		die('Error: '. mysql_error());
	}
	echo "Saved!";
	
	mysql_close($con);
?>